package com.cooldatasoft.domain.daoImpl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.cooldatasoft.domain.dao.EventDao;
import com.cooldatasoft.domain.model.Event;
import com.cooldatasoft.domain.model.User;

public class EventDaoImpl extends GenericDaoImpl<Event, Long> implements EventDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<Event> getAllEventOfUser(User user) {
		Criteria reservationCrit = getSession().createCriteria(Event.class);
		reservationCrit.add(Restrictions.eq("idUser", user));
		reservationCrit.addOrder(Order.asc("start"));
		
		List<Event> res = reservationCrit.list();
		return res;
	}
}
